@extends( 'layout.home' )
@section( 'content' )

    <div class="result_wrap">
        <form>
            <table class="add_tab">
                <tbody>
                <tr>
                    <th>姓名：</th>
                    <td>
                        <input type="text" value="{{$data['name']}}" name="name">
                    </td>
                </tr>
                <tr>
                    <th>账号：</th>
                    <td>
                        <input type="text" value="{{$data['account']}}" name="account">
                    </td>
                </tr>
                <tr>
                    <th>手机号：</th>
                    <td>
                        <input type="text" value="{{$data['phone']}}" name="phone">
                    </td>
                </tr>
                <tr>
                    <th></th>
                    <td>
                        <input type="button" value="确认修改" id="submit">
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
<script src="https://cdn.bootcss.com/layer/3.1.0/layer.js"></script>
<script>
    $("#submit").click(function(){//点击提交
        var name = $("input[name='name']").val();
        var account = $("input[name='account']").val();
        var phone = $("input[name='phone']").val();
        var aid = '{{$data['id']}}';
        if(!name||!account||!phone){
            layer.msg('请填写完整！');
        }
        $.post("{{url('admin')}}/"+aid,{
            '_method':'put',
            '_token':"{{csrf_token()}}",
            name:name,
            account:account,
            phone:phone
        },function(data){
            if(data.code){
                layer.msg(data.msg);
                setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
                    var index=parent.layer.getFrameIndex(window.name);
                    window.parent.location.reload();
                    parent.layer.close(index);
                },2000);
            }else{
                layer.msg(data.msg);
            }
        });
    });
</script>
@endsection
